翻訳と辞書
Words near each other
・ Loose Source Routing
・ Loose Special
・ Loose Stream
・ Loose Tails
・ Loose Talk
・ Loose Talk (song)
・ Loose Talk Costs Lives
・ Loose Tapestries
・ Loose Tubes
・ Loose Tubes (album)
・ Loose Walk
・ Loose wheel nut indicator
・ Loose Women
・ Loop-mediated isothermal amplification
・ Loop-O-Plane
Loop-switch sequence
・ Loop-the-Loop (disambiguation)
・ Loop-the-Loop (song)
・ Loopallu Festival
・ Loopback
・ Loopback device
・ LoopCo
・ Loope, California
・ Loopealse
・ Loopebach
・ Looped
・ Looped square
・ Loopemount, West Virginia
・ Looper
・ Looper (band)


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Loop-switch sequence : ウィキペディア英語版
Loop-switch sequence
A loop-switch sequence (also known as the for-case paradigm〔(The FOR-CASE paradigm ) and (Switched on Loops ) at The Daily WTF〕 or Anti-Duff's Device) is a programming antipattern where a clear set of steps is implemented as a switch-within-a-loop. The loop-switch sequence is a specific derivative of spaghetti code.
It is not necessarily an antipattern to use a switch statement within a loop—it is only considered incorrect when used to model a known sequence of steps. The most common example of the correct use of a switch within a loop is an inversion of control such as an event handler. In event handler loops, the sequence of events is not known at compile-time, so the repeated switch is both necessary and correct (see event-driven programming, event loop and event-driven finite state machine).
Note that this is not a performance antipattern, though it may lead to an inconsequential performance penalty due to the lack of an unrolled loop. Rather, this is a clarity antipattern, as in any non-trivial example, it is much more difficult to decipher the intent and actual function of the code than the more straightforward refactored solution.
==Example==

An event-driven solution would implement a listener interface:

String key = null;
String value = null;
List params = null;
int column = 0;
public void addToken(token)
}

But without the listener, it becomes an example of the antipattern:

// parse a key, a value, then three parameters
String key = null;
String value = null;
List params = new LinkedList();
for (int i = 0; i < 5; i++)

And here is the refactored solution:

// parse a key and value
String key = stream.parse();
String value = stream.parse();
// parse 3 parameters
List params = new LinkedList();
for (int i = 2; i < 5; i++)


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Loop-switch sequence」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.